<template>
<div id="profile">
  <nav-bar class="profile-nav"><div slot="center">我的商城</div></nav-bar>
  <scroll class="content" :pull-upload="true">
<!--    登录注册-->
    <user-info/>
<!--    优惠信息-->
    <account />
<!--    选项卡-->
    <Option></Option>
  </scroll>
</div>
</template>

<script>
import NavBar from "@/components/common/navbar/NavBar";
import Scroll from "@/components/common/scroll/Scroll";
import UserInfo from "@/views/profile/childrenComps/UserInfo";
import Account from "@/views/profile/childrenComps/Account";
import Option from "@/views/profile/childrenComps/Option";
import { getProfileInfo } from "@/network/profile";

export default {
  name: "Profile",
  components: {
    NavBar,
    Scroll,
    UserInfo,
    Account,
    Option
  },
  data() {
    return {
      uBaseInfo: {
        //通过uid到达用户的个人界面
        uid: "",
        uname: "",
        uavatar: ""
      }
    }
  },
  create() {
    this.uBaseInfo.uid = this.$route.params.uid
    this.getProfileInfo(uid)
  },
  methods: {
    async getProfileInfo(uid) {
      let res = await getProfileInfo(uid)
      if(!res.success) {
        this.uBaseInfo = null
      }
      else {
        this.uBaseInfo.uavatar = res.data.data.uImg;
        this.uBaseInfo.uname = res.data.data.name;
      }
      console.log(this.uBaseInfo);
    }
  }

}
</script>

<style scoped>
#profile {
  height: 100vh;
  position: relative;
}
.profile-nav {
  text-align: center;
  color: #fff;
  line-height: 44px;
  background-color: var(--color-tint);
  z-index: 999;
}
</style>
